]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
NotificationDaemon: add rewriteRules infrastructure, use it for xchat
authorDan Winship <danw@gnome.org>
Tue, 16 Feb 2010 22:32:19 +0000 (17:32 -0500)
committerDan Winship <danw@gnome.org>
Mon, 22 Feb 2010 22:09:13 +0000 (17:09 -0500)
Changes notifications like:

    XChat: Private message from: danw (GimpNet) blah...

to

    danw: blah blah blah blah

(the "XChat" being unnecessary since there's already an xchat icon
there anyway.)

https://bugzilla.gnome.org/show_bug.cgi?id=608915

js/ui/notificationDaemon.js

index de747141e28be1811ffda71daee0d23f3e57ef57..6e53f1a7df1c45bc4db1599a12eb7369f9838f6d 100644 (file)
@@ -69,6 +69,16 @@ const Urgency = {
     CRITICAL: 2
 };
 
+const rewriteRules = {
+    'XChat': [
+        { pattern:     /^XChat: Private message from: (\S*) \(.*\)$/,
+          replacement: '&lt;$1&gt;' },
+        { pattern:     /^XChat: New public message from: (\S*) \((.*)\)$/,
+          replacement: '$2 &lt;$1&gt;' },
+        { pattern:     /^XChat: Highlighted message from: (\S*) \((.*)\)$/,
+          replacement: '$2 &lt;$1&gt;' }
+    ]
+};
 function NotificationDaemon() {
     this._init();
 }
@@ -150,6 +160,15 @@ NotificationDaemon.prototype = {
 
         summary = GLib.markup_escape_text(summary, -1);
 
+        let rewrites = rewriteRules[appName];
+        if (rewrites) {
+            for (let i = 0; i < rewrites.length; i++) {
+                let rule = rewrites[i];
+                if (summary.search(rule.pattern) != -1)
+                    summary = summary.replace(rule.pattern, rule.replacement);
+            }
+        }
+
         let notification = new MessageTray.Notification(source, summary, body, true);
         if (actions.length) {
             for (let i = 0; i < actions.length - 1; i += 2)